{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fa367d4f-dddb-43d9-8e97-3f4f15802940",
   "metadata": {},
   "outputs": [],
   "source": [
    "# DEV.GF_Pack_Archice_Will_Delete_for_PyPI_20251122.ipynb\n",
    "# Create by GF 2025-11-22 12:36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5aac733c-5329-49ee-990e-face3376b1d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas\n",
    "import PY3_Pandas_2_Read_Directory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1522301f-a40a-4964-a9a8-a3cf4baf6128",
   "metadata": {},
   "outputs": [],
   "source": [
    "OBJ_PY3_Pandas_2_Read_Directory = PY3_Pandas_2_Read_Directory.PY3_Pandas_2_Read_Directory()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "fa30786d-f02a-47a1-a16c-3124552290c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def Read_Will_Retain_PyPI_Packages(Directory_Pack_Archive_Will_Retain:str):\n",
    "\n",
    "    LIST_DataFrame:list = []\n",
    "    # ..............................................\n",
    "    JSON_Records = OBJ_PY3_Pandas_2_Read_Directory.Read_Directory(Directory_Pack_Archive_Will_Retain, Header = None)\n",
    "    # ..............................................\n",
    "    for Record in JSON_Records:\n",
    "        for df in Record[\"dataframe\"].values():\n",
    "            LIST_DataFrame.append(df)\n",
    "    # ..............................................\n",
    "    return pandas.concat(LIST_DataFrame, ignore_index = True)\n",
    "\n",
    "def Read_Will_Delete_PyPI_Packages(Directory_Pack_Archive_Will_Delete:str):\n",
    "\n",
    "    Pandas_DataFrame = Read_Will_Retain_PyPI_Packages(Directory_Pack_Archive_Will_Retain = Directory_Pack_Archive_Will_Delete)\n",
    "    # ..............................................\n",
    "    return Pandas_DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2ad70f4f-914b-483e-95b4-383ff6ba95aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>a2wsgi==1.10.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>aiologic==0.14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>aiosqlite==0.21.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>alembic==1.16.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>amqp==5.3.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2298</th>\n",
       "      <td>pyparsing==3.1.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2299</th>\n",
       "      <td>python-dateutil==2.8.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2300</th>\n",
       "      <td>six==1.16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2301</th>\n",
       "      <td>wordcloud==1.9.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2302</th>\n",
       "      <td>zipp==3.17.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2303 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                           0\n",
       "0            a2wsgi==1.10.10\n",
       "1           aiologic==0.14.0\n",
       "2          aiosqlite==0.21.0\n",
       "3            alembic==1.16.2\n",
       "4                amqp==5.3.1\n",
       "...                      ...\n",
       "2298        pyparsing==3.1.1\n",
       "2299  python-dateutil==2.8.2\n",
       "2300             six==1.16.0\n",
       "2301        wordcloud==1.9.3\n",
       "2302            zipp==3.17.0\n",
       "\n",
       "[2303 rows x 1 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Will_Retain_PyPI_Packages_DataFrame = Read_Will_Retain_PyPI_Packages(\"./Pack_Archive_Will_Retain\")\n",
    "Will_Retain_PyPI_Packages_DataFrame[0] = Will_Retain_PyPI_Packages_DataFrame[0].apply(lambda x: x.replace('_', '-'))\n",
    "Will_Retain_PyPI_Packages_DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "36b7f79e-0b66-4963-b77f-f86687b938da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>aiohappyeyeballs==2.4.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>aiohttp==3.9.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>aiosignal==1.3.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>annotated-types==0.7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>anyio==4.8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>402</th>\n",
       "      <td>six==1.16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>403</th>\n",
       "      <td>soupsieve==2.4.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>404</th>\n",
       "      <td>tushare==1.2.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>405</th>\n",
       "      <td>urllib3==2.0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>406</th>\n",
       "      <td>websocket-client==0.57.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>407 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            0\n",
       "0     aiohappyeyeballs==2.4.6\n",
       "1              aiohttp==3.9.5\n",
       "2            aiosignal==1.3.2\n",
       "3      annotated-types==0.7.0\n",
       "4                anyio==4.8.0\n",
       "..                        ...\n",
       "402               six==1.16.0\n",
       "403          soupsieve==2.4.1\n",
       "404           tushare==1.2.89\n",
       "405            urllib3==2.0.3\n",
       "406  websocket-client==0.57.0\n",
       "\n",
       "[407 rows x 1 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Will_Delete_PyPI_Packages_DataFrame = Read_Will_Delete_PyPI_Packages(\"./Pack_Archive_Will_Delete\")\n",
    "Will_Delete_PyPI_Packages_DataFrame[0] = Will_Delete_PyPI_Packages_DataFrame[0].apply(lambda x: x.replace('_', '-'))\n",
    "Will_Delete_PyPI_Packages_DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "357514ab-e603-4694-8c09-71f0098f7f74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['PyQtWebEngine==5.15.2',\n",
       " 'Send2Trash==1.8.3',\n",
       " 'altair==5.5.0',\n",
       " 'altgraph==0.17.3',\n",
       " 'async-lru==2.0.4',\n",
       " 'autopep8==2.3.2',\n",
       " 'azure-identity==1.21.0',\n",
       " 'azure-keyvault-secrets==4.9.0',\n",
       " 'babel==2.16.0',\n",
       " 'bleach==6.2.0',\n",
       " 'data-formulator==0.1.7',\n",
       " 'debugpy==1.8.12',\n",
       " 'fastjsonschema==2.21.1',\n",
       " 'fonttools==4.41.0',\n",
       " 'fqdn==1.5.1',\n",
       " 'ipykernel==6.29.5',\n",
       " 'ipython==8.12.0',\n",
       " 'isoduration==20.11.0',\n",
       " 'json5==0.10.0',\n",
       " 'jupyter-client==8.6.3',\n",
       " 'jupyter-console==6.6.3',\n",
       " 'jupyter-core==5.7.2',\n",
       " 'jupyter-events==0.11.0',\n",
       " 'jupyter-events==0.12.0',\n",
       " 'jupyter-lsp==2.2.5',\n",
       " 'jupyter-server-terminals==0.5.3',\n",
       " 'jupyter-server==2.15.0',\n",
       " 'jupyter==1.1.1',\n",
       " 'jupyterlab-pygments==0.3.0',\n",
       " 'jupyterlab-server==2.27.3',\n",
       " 'jupyterlab==4.3.4',\n",
       " 'langchain-core==0.3.40',\n",
       " 'langchain-ollama==0.2.3',\n",
       " 'langsmith==0.3.8',\n",
       " 'mistune==3.1.0',\n",
       " 'namedlist==1.8',\n",
       " 'narwhals==1.26.0',\n",
       " 'nbclient==0.10.2',\n",
       " 'nbconvert==7.16.5',\n",
       " 'nbformat==5.10.4',\n",
       " 'notebook-shim==0.2.4',\n",
       " 'notebook==7.3.2',\n",
       " 'ollama-ocr==0.1.3',\n",
       " 'pandasgui==0.2.14',\n",
       " 'pandocfilters==1.5.1',\n",
       " 'pdf2image==1.17.0',\n",
       " 'pefile==2023.2.7',\n",
       " 'pyarrow==12.0.1',\n",
       " 'pycodestyle==2.12.0',\n",
       " 'pyinstaller-hooks-contrib==2023.5',\n",
       " 'pyinstaller==5.6',\n",
       " 'pynput==1.7.6',\n",
       " 'python-json-logger==3.2.1',\n",
       " 'python-json-logger==3.3.0',\n",
       " 'pywin32-ctypes==0.2.2',\n",
       " 'pywin32==308',\n",
       " 'pywinpty==2.0.14',\n",
       " 'pyzmq==26.2.0',\n",
       " 'qtstylish==0.1.5',\n",
       " 'rfc3339-validator==0.1.4',\n",
       " 'rfc3986-validator==0.1.1',\n",
       " 'streamlit==1.42.0',\n",
       " 'tenacity==8.2.2',\n",
       " 'terminado==0.18.1',\n",
       " 'tinycss2==1.4.0',\n",
       " 'tushare==1.2.89',\n",
       " 'uri-template==1.3.0',\n",
       " 'vega-datasets==0.9.0',\n",
       " 'watchdog==6.0.0',\n",
       " 'webcolors==24.11.1',\n",
       " 'websocket-client==0.57.0',\n",
       " 'wordcloud==1.9.2']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Confirm_Delete:list = []\n",
    "# ..................................................\n",
    "for idx, row in Will_Delete_PyPI_Packages_DataFrame.iterrows():\n",
    "    PyPI_Package = row[0]\n",
    "    if (PyPI_Package not in Will_Retain_PyPI_Packages_DataFrame[0].values):\n",
    "        Confirm_Delete.append(PyPI_Package)\n",
    "# ..................................................\n",
    "Confirm_Delete = list(set(Confirm_Delete))\n",
    "Confirm_Delete.sort()\n",
    "Confirm_Delete"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed19b8f1-5e10-4fbd-8b4a-97d655c78183",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
